// alert message

(function($) {

$.popup = {
    verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels 
    horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/ 
    repositionOnResize: true,           // re-centers the dialog on window resize 
    okButton: '是',                     // text for the OK button 
    cancelButton: '取消',             // text for the Cancel button 
    draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
    messageWidth: 300,
    messageHeight: 100,
    noButton: '否',                     // text for the No button 

    // Private methods 
    _createElement: function(obj) { 
        return $(document.createElement(obj)); 
    },

    _initFrame: function(title) {
        $.popup._createElement('div')
        .attr('id', 'divBg')
        .attr('class', 'popdivBg')
        .css({ 'position': 'absolute', 'top': '0', 'left': '0', 'z-index': '9999', 
            'filter': 'alpha(opacity=70)', 'opacity': '0.5', 
            'width': '100%',
            'height': document.documentElement.scrollHeight + 'px' })
        .appendTo('body'); 

        $.popup._createElement('div')
        .attr('id', 'divOut')
        .attr("class","popdivOut")
        .css({ 'position': 'absolute', 
            'top': ($(window).height() - $.popup.messageHeight) / 2 + $(window).scrollTop() + 'px', 
            'left': ($(window).width() - $.popup.messageWidth) / 2 + $(window).scrollLeft() + 'px', 
            'zIndex': '10000', 'width': $.popup.messageWidth + 'px', 
             'overflow': 'hidden' }) 
        .appendTo('body'); 
        //'border': '1px solid #cef',
        //'height': $.popup.messageHeight + 'px',

        $.popup._createElement('table')
        .attr('id', 'tblOut')
        .attr("width","100%")
        .attr("height","100%")
        .appendTo($('#divOut')); 

        $.popup._createElement('tr')
        .attr('id', 'trTitle0')
        .css({ 'height': '20px'})
        .appendTo($('#tblOut'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle01')
        .css({'width': '20px'})
        .attr('background', getMsgBGImage1())
        .appendTo($('#trTitle0'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle02')
        .attr('background', getMsgBGImage2())
        .appendTo($('#trTitle0'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle03')
        .css({'width': '20px'})
        .attr('background', getMsgBGImage3())
        .appendTo($('#trTitle0'));

        $.popup._createElement('tr')
        .attr('id', 'trTitle1')
        .css({ 'height': '26px'})
        .appendTo($('#tblOut'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle11')
        .attr('align', 'left')
        .attr('rowspan', '3')
        .attr('background', getMsgBGImage4())
        .appendTo($('#trTitle1'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle12')
        .attr('align', 'left')
        .attr('background', getMsgTopBGImage())
        .css({'cursor': 'move', 'background-color': "#FFFFFF"})
        .appendTo($('#trTitle1'));

        $.popup._createElement('div')
        .attr('id', 'divMsg')
        .html(title) 
        .css({'display': 'inline', 'float': 'left', 'padding-left': '8px', 'color' : '#ffffff', 'font-weight': 'bold'})
        .appendTo($('#tdTitle12'));

        $.popup._createElement('div')
        .attr('id', 'divCloseBtn')
        .css({'cursor': 'pointer', 'float': 'right', 'padding-right': '4px', 'z-index': '10002'})
        .appendTo($('#tdTitle12'));

        $.popup._createElement('img')
        .attr('id', 'imgClose')
        .attr('class', 'popAlertImageClose')
        .attr('src', getCloseImage())
        .appendTo($('#divCloseBtn'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle13')
        .attr('align', 'left')
        .attr('rowspan', '3')
        .attr('background', getMsgBGImage6())
        .appendTo($('#trTitle1'));

        $.popup._createElement('tr')
        .attr('id', 'trTitle2')
        .appendTo($('#tblOut'));
        //.attr('height', $.popup.messageHeight - 92 + 'px')

        $.popup._createElement('td')
        .attr('id', 'tdTitle22')
        .attr('align', 'left')
        .css({'vertical-align': 'middle', 'padding-left': '8px', 'padding-right': '8px', 'padding-top': '8px', 'background-color': '#ffffff'})
        .appendTo($('#trTitle2'));

        $.popup._createElement('tr')
        .attr('id', 'trTitle3')
        .attr('height', '26px')
        .appendTo($('#tblOut'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle32')
        .attr('align', 'center')
        .css({'vertical-align': 'bottom', 'background-color': '#ffffff'})
        .appendTo($('#trTitle3'));
        
        $.popup._createElement('tr')
        .attr('id', 'trTitle4')
        .css({ 'height': '20px'})
        .appendTo($('#tblOut'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle41')
        .attr('background', getMsgBGImage7())
        .attr('align', 'left')
        .appendTo($('#trTitle4'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle42')
        .attr('background', getMsgBGImage8())
        .attr('align', 'left')
        .appendTo($('#trTitle4'));

        $.popup._createElement('td')
        .attr('id', 'tdTitle43')
        .attr('background', getMsgBGImage9())
        .attr('align', 'left')
        .appendTo($('#trTitle4'));

        window.onscroll = function(){
            $('#divOut')
            .css({ 'position': 'absolute', 
                'top': ($(window).height() - $('#tdTitle22').attr('clientHeight') - 92) / 2 + $(window).scrollTop() + 'px', 
                'left': ($(window).width() - $.popup.messageWidth) / 2 + $(window).scrollLeft() + 'px', 
                'zIndex': '10000', 'width': $.popup.messageWidth + 'px', 
                 'overflow': 'hidden' });
            //'border': '1px solid #cef',
            //'height': $.popup.messageHeight + 'px',
        };
    },
    
    _showMessage: function(title, msg, value, type, callback) {
        $('#divBg').remove(); 
        $('#divOut').remove(); 
    
        $.popup._initFrame(title);
        $.popup._maintainPosition(true);
        $.popup._outerMove($('#divOut'), $('#trTitle1'));

        switch(type) { 
            case 'alert': 
                $('#tdTitle22').html(msg);
                $('#divOut')
                .css({'top': ($(window).height() - $('#tdTitle22').attr('clientHeight') - 92) / 2 + $(window).scrollTop() + 'px'});

                
//                $.popup._createElement('img')
//                .attr('id', 'imgClose')
//                .attr('class', 'popAlertImageClose')
//                .attr('src', getCloseImage())
//                .appendTo($('#divCloseBtn'));
                
                $.popup._createElement('button')
                .attr('id', 'btnOk')
                .attr('class', 'popbtnOK')
                .text($.popup.okButton) 
                .appendTo($('#tdTitle32'));
                
                $('#btnOk').click( function() { 
                    $.popup._close();
                    callback(true);
                });
                
                $('#btnOk').focus().keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnOk').trigger('click'); 
                });
                
                $('#btnOk').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                    } 
                });
                
                $('#imgClose').click( function() { 
                    $('#btnOk').trigger('click');
                });
                
                break;
            case 'confirm':
                $('#tdTitle22').html(msg);
                $('#divOut')
                .css({'top': ($(window).height() - $('#tdTitle22').attr('clientHeight') - 92) / 2 + $(window).scrollTop() + 'px'});
                
//                $.popup._createElement('img')
//                .attr('id', 'imgClose')
//                .attr('class', 'popAlertImageClose')
//                .attr('src', getCloseImage())
//                .appendTo($('#divCloseBtn'));

                $.popup._createElement('button')
                .attr('id', 'btnOk')
                .attr('class', 'popbtnOK')
                .text($.popup.okButton) 
                .appendTo($('#tdTitle32'));
                
                $.popup._createElement('button')
                .attr('id', 'btnCancel')
                .attr('class', 'popbtnCancel')
                .text($.popup.cancelButton) 
                .appendTo($('#tdTitle32'));
                
                $('#btnOk').click( function() { 
                    $.popup._close();
                    if(callback) callback(true);
                });
                
                $('#btnCancel').click( function() { 
                    $.popup._close();
                    if(callback) callback(false);
                });
                
                $('#btnOk').focus();
//                $('#btnOk').keypress( function(e) { 
////                    if( e.keyCode == 13 ) $('#btnOk').trigger('click'); 
//                });
//                
//                $('#btnCancel').keypress( function(e) { 
////                    if( e.keyCode == 13 ) $('#btnCancel').trigger('click'); 
//                });
                
                $('#btnOk').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnCancel').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnCancel').focus();}; 
                    } 
                });
                $('#btnCancel').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnOk').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnOk').focus();}; 
                    } 
                });
                
                $('#imgClose').click( function() { 
                    $('#btnCancel').trigger('click');
                });
                
                break;
             case 'prompt': 
                $.popup._createElement('input')
                .attr('type', 'text')
                .attr('id', 'txtPrompt')
                .css({ 'width': $('#trTitle2').outerWidth()-56 })
                .val(value)
                .appendTo($('#tdTitle22'));
                $('#divOut')
                .css({'top': ($(window).height() - $('#tdTitle22').attr('clientHeight') - 92) / 2 + $(window).scrollTop() + 'px'});

//                $.popup._createElement('img')
//                .attr('id', 'imgClose')
//                .attr('class', 'popAlertImageClose')
//                .attr('src', getCloseImage())
//                .css({ 'cursor': 'pointer'})
//                .appendTo($('#divCloseBtn'));
                
                $.popup._createElement('button')
                .attr('id', 'btnOk')
                .attr('class', 'popbtnOK')
                .text($.popup.okButton) 
                .css({ 'cursor': 'pointer', 'height': '20px', 'width': '80px' }) 
                .appendTo($('#tdTitle32'));
                
                $.popup._createElement('button')
                .attr('id', 'btnCancel')
                .attr('class', 'popbtnCancel')
                .text($.popup.cancelButton) 
                .css({ 'cursor': 'pointer', 'height': '20px', 'width': '80px', 'margin-left': '40' }) 
                .appendTo($('#tdTitle32'));
                
                $('#btnOk').click( function() {
                    var val = $('#txtPrompt').val();
                    $.popup._close();
                    if(callback) callback(val);
                });
                
                $('#btnCancel').click( function() { 
                    $.popup._close();
                    if(callback) callback(null);
                });
                
                $('#btnOk').focus();
                $('#btnOk').keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnOk').trigger('click'); 
                });
                
                $('#btnCancel').keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnCancel').trigger('click'); 
                });

                $('#txtPrompt').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnOk').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnCancel').focus();}; 
                    } 
                });
                $('#btnOk').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnCancel').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#txtPrompt').focus();}; 
                    } 
                });
                $('#btnCancel').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#txtPrompt').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnOk').focus();}; 
                    } 
                });
                
                $('#imgClose').click( function() { 
                    $('#btnCancel').trigger('click');
                });
                
                break;
             case 'confirmNo':
                 $('#tdTitle22').html(msg);
                 $('#divOut')
                 .css({'top': ($(window).height() - $('#tdTitle22').attr('clientHeight') - 92) / 2 + $(window).scrollTop() + 'px'});


//                $.popup._createElement('img')
//                .attr('id', 'imgClose')
//                .attr('class', 'popAlertImageClose')
//                .attr('src', getCloseImage())
//                .appendTo($('#divCloseBtn'));

                $.popup._createElement('button')
                .attr('id', 'btnOk')
                .attr('class', 'confirmbtnOK')
                .text($.popup.okButton) 
                .appendTo($('#tdTitle32'));

                $.popup._createElement('button')
                .attr('id', 'btnNo')
                .attr('class', 'confirmbtnNo')
                .text($.popup.noButton) 
                .appendTo($('#tdTitle32'));

                $.popup._createElement('button')
                .attr('id', 'btnCancel')
                .attr('class', 'confirmbtnCancel')
                .text($.popup.cancelButton) 
                .appendTo($('#tdTitle32'));
                
                $('#btnOk').click( function() { 
                    $.popup._close();
                    if(callback) callback('OK');
                });
                
                $('#btnNo').click( function() { 
                    $.popup._close();
                    if(callback) callback('NO');
                });
                
                $('#btnCancel').click( function() { 
                    $.popup._close();
                    if(callback) callback('CANCEL');
                });
                
                $('#btnOk').focus();
                $('#btnOk').keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnOk').trigger('click'); 
                });
                
                $('#btnNo').keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnNo').trigger('click'); 
                });
                
                $('#btnCancel').keypress( function(e) { 
//                    if( e.keyCode == 13 ) $('#btnCancel').trigger('click'); 
                });

                $('#btnOk').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnNo').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnCancel').focus();}; 
                    } 
                });
                $('#btnNo').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnCancel').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnOk').focus();}; 
                    } 
                });
                $('#btnCancel').live('keydown', function(e) { 
                    var keyCode = e.keyCode || e.which; 
                    if (keyCode == 9) { 
                        e.preventDefault(); 
                        if( keyCode == 9 ) {$('#btnOk').focus();}; 
                        if( e.shiftKey == true && keyCode == 9 ) {$('#btnNo').focus();}; 
                    } 
                });
                
                $('#imgClose').click( function() { 
                    $('#btnCancel').trigger('click');
                });
                
                break;
        }
    },
    
    _close: function() { 
        $('#divBg').hide(); 
        $('#divOut').hide(); 
    },
    _showDialogClose: function(div) { 
        $('#divBg').hide(); 
        $('#divOut').hide(); 
        $('#' + $("#divDialogID").val()).attr('style', 'display:none');
        $("#" + $("#divDialogID").val()).appendTo("body")
    },
    _reposition: function() { 
        var top = (($(window).height() / 2) - ($('#divOut').outerHeight() / 2)) + $.popup.verticalOffset; 
        var left = (($(window).width() / 2) - ($('#divOut').outerWidth() / 2)) + $.popup.horizontalOffset; 
        if( top < 0 ) top = 0; 
        if( left < 0 ) left = 0; 

        // IE6 fix 
        if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop(); 

        $('#divOut').css({ 
            top: top + 'px', 
            left: left + 'px' 
        }); 
        $('#divBg').height( $(document).height() ); 
    },

    _maintainPosition: function(status) { 
        if( $.popup.repositionOnResize ) { 
            switch(status) { 
                case true:
                    $(window).bind('resize', function() { 
                        $.popup._reposition(); 
                    }); 
                    break; 
                case false: 
                    $(window).unbind('resize'); 
                    break; 
            } 
        } 
    },
    
    _outerMove: function(outerID, titleID) { 
        var _x;
        var _y;
        var _xx;
        var _yy;

        titleID.mousedown(function(event){
            var offset = $(this).offset();
            _x=event.clientX-offset.left;
            _y=event.clientY-offset.top+20;
            $(this).bind('mousemove', (function(event){
                _xx=event.clientX-_x;
                _yy=event.clientY-_y;
                outerID.css('top',_yy);
                outerID.css('left',_xx);
                })
            );
        });
        
        titleID.mouseup(function(event){
            $(this).unbind('mousemove');
        });
        
        titleID.mouseout(function(event){
            $(this).unbind('mousemove');
        });
    },
    
    _closeSelect: function () {
        if(document.getElementById( "chooseDiv" )!= null){
            document.body.removeChild( document.getElementById( "chooseDiv" ));
        }
    },
    
    // Public methods 
    alert: function(message, title, callback, width, height) { 
        if( title == null ) {
            title = 'アラート';
        } else if ( title == "" ) {
            title = 'アラート';
        }
        if(width != null)   $.popup.messageWidth = width;else $.popup.messageWidth = 300;
        if(height != null)   $.popup.messageHeight = height;else $.popup.messageHeight = 120;
            $.popup._showMessage(title, message, null, 'alert', function(result) { 
                if(callback) callback(result); 
            });
    },

    confirm: function(message, title, callbackOk, callbackCancel, data, width, height) {
        if( title == null ) {
            title = '确认';
        } else if ( title == "" ) {
            title = '确认';
        }
        if(width != null)   $.popup.messageWidth = width;else $.popup.messageWidth = 300;
        if(height != null)   $.popup.messageHeight = height;else $.popup.messageHeight = 120;
                $.popup._showMessage(title, message, null, 'confirm', function(result) {
                    if(result){
                        if(callbackOk) callbackOk(data);
                    }else{
                        if(callbackCancel) callbackCancel(data);
                    }
                });
    },

    confirmNo: function(message, title, callbackOk, callbackCancel, callbackNo, data, width, height) {
        if( title == null ) {
            title = '确认';
        } else if ( title == "" ) {
            title = '确认';
        }
        if(width != null)   $.popup.messageWidth = width;else $.popup.messageWidth = 350;
        if(height != null)   $.popup.messageHeight = height;else $.popup.messageHeight = 120;
                $.popup._showMessage(title, message, null, 'confirmNo', function(result) {
                    if(result=='OK'){
                        if(callbackOk) callbackOk(data);
                    }else if(result=='CANCEL'){
                        if(callbackCancel) callbackCancel(data);
                    }else{
                        if(callbackNo) callbackNo(data);
                    }
                });
    },

    prompt: function(message, value, title, callback, width, height) { 
        if( title == null ) {
            title = '提示';
        } else if ( title == "" ) {
            title = '提示';
        }
        if(width != null)   $.popup.messageWidth = width;else $.popup.messageWidth = 300;
        if(height != null)   $.popup.messageHeight = height;else $.popup.messageHeight = 120;
            $.popup._showMessage(title, message, value, 'prompt', function(result) { 
                if(callback) callback(result); 
            }); 
    },

    showDialog: function(divID, dialogTitle, dialogWidth, dialogHeight) {
        var width; 
        var height;
        var title;
        
        if(dialogWidth) {
            width = dialogWidth;
        } else {
            width = document.documentElement.clientWidth / 2;
        }
        
        if(dialogHeight) {
            height = dialogHeight;
        } else {
            height = document.documentElement.clientHeight / 2;
        }
        
        if(dialogTitle) {
            title = dialogTitle;
        } else {
            title = 'Dialog';
        }
        

        $('#divBg').remove(); 
        $('#divOut').remove(); 
        $('#' + divID).attr('style', 'display:true');
        $.popup._createElement('div')
        .attr('id', 'divBg')
        .attr('class','popdivBg')
        .css({ 'position': 'absolute', 'top': '0', 'left': '0', 'z-index': '9999', 
            'filter': 'alpha(opacity=70)', 'opacity': '0.5', 
            'width': '100%', 
            'height': document.documentElement.scrollHeight + 'px' })
        .appendTo('body'); 

        $.popup._createElement('div')
        .attr('id', 'divOut')
        .attr("class","popdivOut")
        .css({ 'position': 'absolute', 
            'top': ($(window).height() - height) / 2 + $(window).scrollTop() + 'px', 
            'left': ($(window).width() - width) / 2 + $(window).scrollLeft() + 'px', 
             'zIndex': '10000', 'width': width + 'px', 
            'height': height + 'px', 'overflow': 'hidden' }) 
        .appendTo('body');
        //'border': '1px solid #cef',

        $.popup._createElement('div')
        .attr('id', 'divTrans')
        .css({ 'height': '20px'})
        .appendTo($('#divOut'));
        
        $.popup._createElement('div')
        .attr('id', 'divTitle')
        .attr("class","popDilogTitle")
        .css({ 'textAlign': 'left', 'cursor': 'move', 'height': '20px', 'vertical-align': 'middle' })
        .html(title)
        .appendTo($('#divOut'));
        
        $.popup._outerMove($('#divOut'), $('#divTitle'));
        
        $.popup._createElement('img')
        .attr('id', 'imgClose')
        .attr('src', getCloseImage())
        .click($.popup._showDialogClose)
        .css({ 'position': 'absolute', 'cursor': 'pointer', 'right': '10px', 'top': '25px'})
        .appendTo($('#divTitle'));
        $.popup._createElement('div')
        .attr("class","popDilogDiv")
        .css({'textAlign': 'center', 'padding': '12px', 
            'height': height - $('#divTitle').outerHeight(), 'overflow': 'auto'})
        .html($('#' + divID))
        .appendTo($('#divOut'));
        $.popup._createElement('input')
        .attr("id", "divDialogID")
        .attr("type", "hidden")
        .val(divID)
        .appendTo($('#divOut'));
    },
    
    select:function (objId,data,divWidth){
        var objId = "#" + objId;
        if(divWidth == null || divWidth == ""){
            divWidth = 500;
        }
        var objNewDiv = document.createElement("div");
        objNewDiv.setAttribute('id', 'chooseDiv');
        objNewDiv.style.left = jQuery(objId).offset().left;
        objNewDiv.style.top = jQuery(objId).offset().top + jQuery(objId).get(0).offsetHeight;
        objNewDiv.style.width = divWidth ;
        objNewDiv.style.zIndex = '10001';
        objNewDiv.style.position = 'absolute';
        objNewDiv.className = 'chooseDivCss';
        objNewDiv.style.overflow='auto';
        objNewDiv.onmousedown=function(event){var event=event?event:window.event; event.cancelBubble=true;};
        var len = eval(data).length;
        var sonParams = new Array(len);
        var str = "<div id='selectDiv' class='selectDivCss'><br>";
        for(var i = 0; i < len ; i++){
            sonParams[i] = data[i].sonParams;
            str += "<div><div class='chooseName'><span>|</span>" + data[i].fatherParams + "</div><ul>";
            var sonParamArray = data[i].sonParams.split("+");
            for(var j = 0; j<sonParamArray.length; j++){
                str += "<li><a id='chooseA' href='#'>" + sonParamArray[j] + "</a></li>";
            }
            str += "</ul><div class='chooseDivClear'></div></div>";
        }
        str += "</div>" 
        objNewDiv.innerHTML = str;
        document.body.appendChild(objNewDiv);
       
        jQuery("#chooseA").live("click", function(event){
           jQuery(objId).val(jQuery(this).html());
           _closeSelect();
        });
        
        jQuery("body").live("click", function(event){
            var ob = event.srcElement ? event.srcElement : event.target;
            var event=(event)? event: (window.event? window.event:null);
            var id = jQuery(ob).attr('id');
            if(jQuery("#chooseDiv").get(0) != undefined){//div is not null
                var divX_start = jQuery(objId).offset().left;
                var divX_end =  jQuery(objId).offset().left + divWidth;
                var divY_start = jQuery(objId).offset().top + jQuery(objId).get(0).offsetHeight;
                var divY_end = divY_start + jQuery("#chooseDiv").get(0).offsetHeight;
                if((event.clientX < divX_start || divX_end < event.clientX || event.clientY < divY_start || divY_end < event.clientY) && (objId != ("#"+id)) ){
                    _closeSelect();
                }
            }
         });
    }
}

Jalert = function(message, title, callback, width, height){
    $.popup.alert(message, title, callback, width, height);
};

Jconfirm = function(message, title, callbackOk, callbackCancel, data, width, height){
    $.popup.confirm(message, title, callbackOk, callbackCancel, data, width, height);
};

JconfirmNo = function(message, title, callbackOk, callbackCancel, callbackNo, data, width, height){
    $.popup.confirmNo(message, title, callbackOk, callbackCancel, callbackNo, data, width, height);
};

Jprompt = function(message, value, title, callback, width, height){
    $.popup.prompt(message, value, title, callback, width, height);
};

Jdialog = function(divID, dialogTitle, dialogWidth, dialogHeight) {
    $.popup.showDialog(divID, dialogTitle, dialogWidth, dialogHeight);
};

Jselect = function(objId,data,divWidth) {
    $.popup.select(objId,data,divWidth);
};

JdialogClose = function() {
    $.popup._showDialogClose();
};

})(jQuery);

